package com.hangzhou.xyj.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.hangzhou.xyj.manager.IntentManager;
import com.hangzhou.xyj.model.type.EIntentTagType;
import com.hangzhou.xyj.ui.activity.HomePageActivity;
import com.hangzhou.xyj.utils.constants.DataKey;
import com.hyphenate.chat.EMMessage;
import com.hyphenate.easeui.ui.EaseChatFragment;
import com.hyphenate.easeui.widget.chatrow.EaseCustomChatRowProvider;

/**
 * Created by neo.duan on 2016/5/6.
 * 自定义聊天页面继承环信的
 */
public class MyEaseChatFragment extends EaseChatFragment {

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        /***初始化标题栏****/
        initTop();
        /***初始化内容view****/
        initViews();
        /***初始化事件监听****/
        initListeners();
        /***初始化数据****/
        initDatas();
    }

    private void initTop() {
        //隐藏环信的title
        hideTitleBar();
    }

    private void initViews() {

    }

    private void initListeners() {
        setChatFragmentListener(new EaseChatFragmentListener() {
            /**
             * 设置消息扩展属性
             */
            @Override
            public void onSetMessageAttributes(EMMessage message) {

            }

            /**
             * 进入会话详情
             */
            @Override
            public void onEnterToChatDetails() {

            }

            /**
             * 用户头像点击事件
             * @param userId
             */
            @Override
            public void onAvatarClick(String userId) {
                Intent intentHomePage = new Intent(getActivity(), HomePageActivity.class);
                intentHomePage.putExtra(DataKey.INDEX, Integer.valueOf(userId));
                intentHomePage.putExtra(DataKey.INTENT_TAG, EIntentTagType.TAG_PERSONAL_INFO.getValue());
                IntentManager.getInstance().goHomePageActivity(getActivity(), intentHomePage);
            }

            /**
             * 消息气泡框点击事件
             */
            @Override
            public boolean onMessageBubbleClick(EMMessage message) {
                return false;
            }

            /**
             * 消息气泡框长按事件
             */
            @Override
            public void onMessageBubbleLongClick(EMMessage message) {

            }

            /**
             * 扩展输入栏item点击事件,如果要覆盖EaseChatFragment已有的点击事件，return true
             * @param view
             * @param itemId
             * @return
             */
            @Override
            public boolean onExtendMenuItemClick(int itemId, View view) {
                return false;
            }

            /**
             * 设置自定义chatrow提供者
             * @return
             */
            @Override
            public EaseCustomChatRowProvider onSetCustomChatRowProvider() {
                return null;
            }
        });
    }

    private void initDatas() {

    }
}
